//
//  HQHListCollectionViewCell.m
//  LastOne
//
//  Created by 小柠檬 on 15/11/3.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "HQHListCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "FitHeader.h"
#import "NightHeader.h"
@implementation HQHListCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        _coverimgImageView = [[UIImageView alloc]init];
        _coverimgImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
        [self.contentView addSubview:_coverimgImageView];
        
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.frame = CGRectMake(2 * FitWidth, _coverimgImageView.frame.origin.y + 90 * FitHeight, 100 * FitWidth, 25 * FitHeight);
        _nameLabel.textColor = [UIColor whiteColor];
//        [_nameLabel NightWithType:UIViewColorTypeNormal];
        [self.contentView addSubview:_nameLabel];
 
        
    }
    return self;
}

-(void)setListModel:(HQHListModel *)listModel
{
    if (_listModel != listModel) {
        _listModel = listModel;
        _nameLabel.font = [UIFont systemFontOfSize:15];
        NSString *result = [NSString stringWithFormat:@"%@ %@", listModel.name, listModel.enname];
        [_coverimgImageView sd_setImageWithURL:[NSURL URLWithString:listModel.coverimg] placeholderImage:[UIImage imageNamed:@"placeholder"]];
        NSString *keyWord = [NSString stringWithFormat:@" %@", listModel.enname];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:result];
        NSRange range = [result rangeOfString:keyWord];
        [attributedString setAttributes:[NSMutableDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:10], NSFontAttributeName, nil] range:range];
        _nameLabel.attributedText = attributedString;
        
    }
    
    
}














/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
